﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace WpUserControls.UserControls
{
    public partial class RoundCornerTextBox : UserControl
    {
        public RoundCornerTextBox()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(RoundCornerTextBox_Loaded);
            textBox.TextChanged += new TextChangedEventHandler(textBox_TextChanged);
        }

        void textBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (TextChanged != null)
            {
                TextChanged(sender, e);
            }
        }

        void RoundCornerTextBox_Loaded(object sender, RoutedEventArgs e)
        {
            textBox.SetHint(textBlock, textBlock.Text);
        }

        public event EventHandler<TextChangedEventArgs> TextChanged;

        [Browsable(true)]
        public Brush BorderBackground
        {
            get
            {
                return border.Background;
            }
            set
            {
                border.Background = value;
            }
        }

        [Browsable(true)]
        public Thickness BorderPadding
        {
            get
            {
                return border.Padding;
            }
            set
            {
                border.Padding = value;
            }
        }

        [Browsable(true)]
        public new Thickness BorderThickness
        {
            get
            {
                return border.BorderThickness;
            }
            set
            {
                border.BorderThickness = value;
            }
        }

        [Browsable(true)]
        public new Brush BorderBrush
        {
            get
            {
                return border.BorderBrush;
            }
            set
            {
                border.BorderBrush = value;
            }
        }

        [Browsable(true)]
        public CornerRadius CornerRadius
        {
            get
            {
                return border.CornerRadius;
            }
            set
            {
                border.CornerRadius = value;
            }
        }

        [Browsable(true)]
        public bool IsReadOnly
        {
            get
            {
                return textBox.IsReadOnly;
            }
            set
            {
                textBox.IsReadOnly = value;
            }
        }

        [Browsable(true)]
        public string Text
        {
            get
            {
                return textBox.Text;
            }
            set
            {
                textBox.Text = value;
                textBlock.Visibility = string.IsNullOrEmpty(textBox.Text) ? Visibility.Visible : Visibility.Collapsed;
            }
        }

        [Browsable(true)]
        public int MaxLength
        {
            get
            {
                return textBox.MaxLength;
            }
            set
            {
                textBox.MaxLength = value;
            }
        }

        [Browsable(false)]
        public InputScope InputScope
        {
            get
            {
                return textBox.InputScope;
            }
            set
            {
                textBox.InputScope = value;
            }
        }

        [Browsable(true)]
        public Brush TextBoxBackground
        {
            get
            {
                return textBox.Background;
            }
            set
            {
                textBox.Background = value;
            }
        }

        [Browsable(true)]
        public Brush TextBoxBorderBrush
        {
            get
            {
                return textBox.BorderBrush;
            }
            set
            {
                textBox.BorderBrush = value;
            }
        }

        [Browsable(true)]
        public Thickness TextBoxBorderThickness
        {
            get
            {
                return textBox.BorderThickness;
            }
            set
            {
                textBox.BorderThickness = value;
            }
        }

        [Browsable(true)]
        public Brush TextBoxForeground
        {
            get
            {
                return textBox.Foreground;
            }
            set
            {
                textBox.Foreground = value;
            }
        }

        [Browsable(true)]
        public Thickness TextBoxMargin
        {
            get
            {
                return textBox.Margin;
            }
            set
            {
                textBox.Margin = value;
            }
        }

        [Browsable(true)]
        public string WaterMark
        {
            get
            {
                return textBlock.Text;
            }
            set
            {
                textBlock.Text = value;
            }
        }

        [Browsable(true)]
        public Brush WaterMarkForeground
        {
            get
            {
                return textBlock.Foreground;
            }
            set
            {
                textBlock.Foreground = value;
            }
        }

        [Browsable(true)]
        public Thickness WaterMarkMargin
        {
            get
            {
                return textBlock.Margin;
            }
            set
            {
                textBlock.Margin = value;
            }
        }
    }
}
